package com.yimi.yinhepda.adapter.RecycleAdapter;

import android.content.Context;
import android.view.View;

import com.yimi.yinhepda.R;
import com.pda.ym.base.CommonRecycleAdapter;
import com.pda.ym.base.CommonViewHolder;
import com.yimi.yinhepda.db.table.MoveStockTaskCacheTable;

import java.util.List;

/**
 * @author: lj
 * Date: 2018/12/24
 * Description:移库装卸暂存数据适配器
 */
public class MoveStockCacheAdapter extends CommonRecycleAdapter<MoveStockTaskCacheTable> {

    private Context mContext;
    private CommonViewHolder.onItemCommonClickListener mCommonClickListener;

    public MoveStockCacheAdapter(Context context, List<MoveStockTaskCacheTable> dataList, CommonViewHolder.onItemCommonClickListener commonClickListener) {
        super(context, dataList, R.layout.adapter_move_stock_cache_item);
        this.mContext = context;
        this.mCommonClickListener = commonClickListener;

    }

    @Override
    public void bindData(CommonViewHolder holder, MoveStockTaskCacheTable data, int position) {
        holder.setText(R.id.tv_moveTaskNo, data.getTaskNo());
        holder.setText(R.id.tv_moveInName, data.getMoveInName());
        holder.setText(R.id.tv_carNo, data.getCarNo());
        holder.setText(R.id.tv_piaoNum, data.getPiaoNum() + "");
        if(data.getOperType() == 1){
            holder.setText(R.id.tv_loadType, "装");
        }else{

            holder.setText(R.id.tv_loadType, "卸");
        }

        holder.setCommonClickListener(mCommonClickListener);
        View view = holder.itemView;
        if (data.isCheck()) {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.yellow));
        } else {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.white));
        }
    }
}
